﻿using System.Net;
using System.Net.Sockets;

namespace WebTranslator {
	public abstract class ServerProtocol : Protocol {
		public TcpListener tcpListener;
		public void StartListener(int port) {
			tcpListener = new TcpListener(StartingApplicationPorts.ChosenAddress, port);
			tcpListener.Start();
		}
		public void AcceptSocket() {
			Socket socketForClient = tcpListener.AcceptSocket();
			if (socketForClient.Connected) {
				SetSockets(socketForClient);
			}
		}
		public abstract void Listen();
		public override void Disconnect() {
			base.Disconnect();
			tcpListener.Stop();
		}
	}
}
